package grimbo.goodwinfooty.processing;

import grimbo.goodwinfooty.CSV2List;

import java.io.IOException;
import java.util.List;
import java.util.Map;

public class CSV2UntypedListProcessor implements Processor {
	public final static String CTX_CSV_BYTES = "csvBytes";
	public final static String CTX_UNTYPED_LIST = "untypedList";

	public String process(Map context) throws Exception {
		byte[] csvBytes = (byte[]) context.get(CTX_CSV_BYTES);
		List list = csv2List(csvBytes);
		context.put(CTX_UNTYPED_LIST, list);
		return null;
	}

	private List csv2List(byte[] csvBytes) throws IOException {
		CSV2List csv2List = new CSV2List();
		csv2List.setLastLineValue("END-OF-PLAYERS");
		return csv2List.convertCSV2List(csvBytes);
	}
}
